<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var arr = [124,11,51,6,124,7,3,34,123,47,3,214,4,67,8,54,7,124]
        var minIndex,tmp;
        for(var i = 0;i<arr.length-1;i++){
            minIndex = i;
            for(var j = i+1;j<arr.length;j++){
                if(arr[minIndex]>arr[j]){
                    minIndex = j;
                }
            }
            tmp = arr[i];
            arr[i] = arr[minIndex];
            arr[minIndex] = tmp;
        }

        console.log(arr);
    </script>
</head>
<body>
    
</body>
</html>